using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Dimok.Exceptions;
using Data;

namespace Dimok.Aspx.Manager.Underwriting {
	public partial class InstantID : System.Web.UI.Page {
		protected void Page_Load(object sender, System.EventArgs e) {
			try{
				UOX uox = new UOX();
				string html = "";
				DataSet ds = SQL.ExecuteDatasetEx(uox.db,"SELECT ID,ISNULL(InstantIDScore,-1)InstantIDScore,InstantIDHTML,Pos FROM Borrower(@LoanID,DEFAULT) WHERE LastName > ''",uox.applIDSec);
				foreach(DataRow row in ds.Tables[0].Rows )
					if( (int)row["InstantIDScore"] == -1 ){
						int borrID = (int)row["ID"];
						string[] instID  = uox.Accurint.InstantID(borrID);
						html += instID[1];
						//DataTable dt = ds.Clone().Tables[0];
						//dt.Rows.Add(new object[]{borrID,instID[0],instID[1]});
						//SQL.UpdateDataSet(dt,uox.db,"SELECT ID,InstantIDScore,InstantIDHTML FROM t_Borrower WHERE ID=@BID",borrID);
					}else
						html += row["InstantIDHTML"];
				Response.Write(html);
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e) {
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent() {    
		}
		#endregion
	}
}
